/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package entity;

import java.io.Serializable;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;

/**
 *
 * @author Elise
 */
@Entity
@NamedQueries({
    @NamedQuery(
        name = "findAccessoryByManufacturerAndMake",
        query = " SELECT a" +
                " FROM Accessory a" +
                " WHERE LOWER(a.manufacturer) = LOWER(:entry)" +
                " OR LOWER(a.make) = LOWER(:entry)" +
                " ORDER BY a.price"
    )
})
@DiscriminatorValue("ACC")
public class Accessory extends Product implements Serializable{

    private String accessoryType;
    private String make;
    private String manufacturer;

    public String getAccessoryType()                 {return accessoryType;}
    public void setAccessoryType(String accessoryType)        {this.accessoryType = accessoryType;}
    public String getMake()                 {return make;}
    public void setMake(String m)           {this.make = m;}
    public String getManufacturer()         {return manufacturer;}
    public void setManufacturer(String m)   {this.manufacturer = m;}
    @Override
    public String getName()             { return manufacturer + " " + make; }

    public Accessory(double price, String accessoryType, String make, String manufacturer){
        this.price = price;
        this.accessoryType = accessoryType;
        this.make = make;
        this.manufacturer = manufacturer;
    }

    public Accessory(){}

    @Override
    public String toString() {
        return "model.AccessoryEntity[make=" + make + "]\n" +
               "model.AccessoryEntity[manufacturer=" + manufacturer + "]\n" +
               "model.AccessoryEntity[price=" + price + "]\n";
    }
}
